home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / wink24h / src / oak.c < prev    next >
Text File  |  1994-06-01  |  2KB  |  124 lines

  1. #include    <stdio.h>
  2. #include    <ctype.h>
  3. #include    <kkstr2.h>
  4. #include    "defs.h"
  5.  
  6. #define    MAX_MAC    512
  7.  
  8. extern char    *Act_vram();
  9. extern void    wrtstr();
  10. extern void    memcpy();
  11. extern void    memset();
  12. extern int    strlen();
  13. extern void    locate();
  14. extern void    Dsp_box_vram();
  15. extern char    *SPCSTR;
  16.  
  17. short  ReWrt_flg=FALSE;
  18.  
  19. static struct _MACRO {
  20.        int      mc_ch;
  21.        unsigned mc_ec;
  22.     } mac_key[MAX_MAC+1];
  23. static int    mac_cnt=0;
  24. static int    mac_max=0;
  25. static int    mac_flg=0;
  26.  
  27. static int       ch_bak;
  28. static unsigned ec_bak;
  29. static int       hit_flg=FALSE;
  30.  
  31. void    Tango_Touroku(char *str)
  32. {
  33.     int     x;
  34.     char    *vp;
  35.  
  36.     memset(str,80,0);
  37.     vp = (char *)Act_vram();
  38.     for ( x = Cur_X ; x < MAX_X ; x++ ) {
  39.     if ( (unsigned char)(*(str++) = *(vp+1)) < ' ' )
  40.         *(str-1) = ' ';
  41.     vp += 2;
  42.     }
  43. }
  44.  
  45. void    mac_save()
  46. {
  47.     switch(mac_flg) {
  48.     case 0: case 2:
  49.     mac_flg = 1;
  50.     mac_max = 0;
  51.     wrtstr("只今キ-マクロを定義中です",30,1,0x15);
  52.     break;
  53.     case 1:
  54.     mac_flg = 2;
  55.     mac_cnt = 0;
  56.     mac_max--;
  57.     wrtstr(SPCSTR,30,1,0x1F);
  58.     break;
  59.     }
  60. }
  61. void    mac_go()
  62. {
  63.     if ( mac_flg == 2 ) {
  64.     mac_flg = 3;
  65.     mac_cnt = 0;
  66.     }
  67. }
  68. int    kbhit()
  69. {
  70.     if ( hit_flg != FALSE )
  71.     return 1;
  72.  
  73.     if ( mac_flg == 3 ) {
  74.     if ( mac_cnt < mac_max ) {
  75.         hit_flg = TRUE;
  76.         ch_bak = mac_key[mac_cnt].mc_ch;
  77.         ec_bak = mac_key[mac_cnt].mc_ec;
  78.         mac_cnt++;
  79.         return 1;
  80.     } else {
  81.         mac_flg = 2;
  82.         mac_cnt = 0;
  83.     }
  84.     }
  85.  
  86.   do {
  87.     while ( (ch_bak = KYB_read(1,&ec_bak)) != 0xFFFF ) {
  88.     if ( ch_bak & 0x8000 || (ec_bak & 0xFF00) > 0x5100 )
  89.         ch_bak = 0xFFFF;
  90.     switch(ec_bak & 0xFF00) {
  91.     case 0xFF00:
  92.         break;
  93.  
  94.     default:
  95.         hit_flg = TRUE;
  96.         if ( mac_flg == 1 && mac_max < MAX_MAC ) {
  97.         mac_key[mac_max].mc_ch = ch_bak;
  98.         mac_key[mac_max].mc_ec = ec_bak;
  99.         mac_max++;
  100.         }
  101.         return 1;
  102.     }
  103.     }
  104.   } while ( KAN_inpchk() == KAN_MISET );
  105.  
  106.     return 0;
  107. }
  108. int    Get_key(ec)
  109. unsigned *ec;
  110. {
  111.     while ( kbhit() == 0 );
  112.     hit_flg = FALSE;
  113.     *ec = ec_bak & 0xFF14;
  114.     return ch_bak;
  115. }
  116. int    getch()
  117. {
  118.     int       ch;
  119.     unsigned  ec;
  120.  
  121.     while ( (ch = Get_key(&ec)) == 0xFFFF );
  122.     return ch;
  123. }
  124.